package com.macro.mall.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.BmsNarratorThemeDetail;
import com.macro.mall.dto.BmsNarratorThemeParam;
import com.macro.mall.model.BmsNarratorTheme;
import com.macro.mall.service.BmsNarratorThemeService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;

@Controller
@Api(tags = "BmsNarratorThemeController")
@Tag(name = "BmsNarratorThemeController", description = "讲解项目-主题")
@RequestMapping("/narratorTheme")
public class BmsNarratorThemeController {

    @Autowired
    private BmsNarratorThemeService bmsNarratorThemeService;

    @ApiOperation("分页查询讲解项目-主题")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsNarratorTheme>> getList(@RequestBody BmsNarratorThemeParam bmsNarratorThemeParam) {
        List<BmsNarratorTheme> bmsNarratorThemeList = bmsNarratorThemeService.getList(bmsNarratorThemeParam);
        return CommonResult.success(CommonPage.restPage(bmsNarratorThemeList));
    }

    @ApiOperation("分页查询讲解项目-主题")
    @RequestMapping(value = "/findAllList", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> findAllList() {
        return CommonResult.success(bmsNarratorThemeService.findAllList());
    }

    @ApiOperation("添加讲解项目-主题")
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> create(@RequestBody BmsNarratorThemeParam bmsNarratorThemeParam) {
        int count = bmsNarratorThemeService.create(bmsNarratorThemeParam);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }


    @ApiOperation("修改讲解项目-主题")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> update(@RequestBody BmsNarratorThemeParam bmsNarratorThemeParam) {
        int count = bmsNarratorThemeService.update(bmsNarratorThemeParam);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }

    @ApiOperation("根据id获取讲解项目-主题信息")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<BmsNarratorThemeDetail> getItem(@PathVariable Long id) {
        BmsNarratorThemeDetail bmsNarratorThemeDetail = bmsNarratorThemeService.getItem(id);
        return CommonResult.success(bmsNarratorThemeDetail);
    }

    @ApiOperation("删除讲解项目-主题")
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> delete(@RequestParam("ids") List<Long> ids) {
        int count = bmsNarratorThemeService.delete(ids);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }

}
